package pl.edu.agh.admin.gui;

import java.util.Calendar;

public class FinalPytonCalendar88Utils 
{
    static Calendar toNearestWholeMinute(Calendar calendar)
    {
	    Calendar c = (Calendar)calendar.clone();
	
	    if (c.get(Calendar.SECOND) >= 30)
	        c.add(Calendar.MINUTE, 1);
	
	    c.set(Calendar.SECOND, 0);
	
	    return c;
    }

    
    
    static Calendar toNearestWholeHour(Calendar calendar) 
    {
	    Calendar c = (Calendar)calendar.clone();
	
	    if (c.get(Calendar.MINUTE) >= 30)
	        c.add(Calendar.HOUR, 1);
	
	    c.set(Calendar.MINUTE, 0);
	    c.set(Calendar.SECOND, 0);
	
	    return c;
    }

    
    
    static Calendar toNearestWholeDay(Calendar calendar) 
    {
	    Calendar c = (Calendar)calendar.clone();
	
	    if (c.get(Calendar.HOUR) >= 12)
	        c.add(Calendar.HOUR, 24);
	
	    c.set(Calendar.HOUR, 0);	    
	    c.set(Calendar.MINUTE, 0);
	    c.set(Calendar.SECOND, 0);
	
	    return c;
    }

    
    
    static Calendar toWholeMinute(Calendar calendar)
    {
	    Calendar c = (Calendar)calendar.clone();
	
	    c.set(Calendar.SECOND, 0);
	
	    return c;
    }

    
    
    static Calendar toWholeHour(Calendar calendar) 
    {
	    Calendar c = (Calendar)calendar.clone();
		
	    c.set(Calendar.MINUTE, 0);
	    c.set(Calendar.SECOND, 0);
	
	    return c;
    }

    
    
    static Calendar toWholeDay(Calendar calendar) 
    {
	    Calendar c = (Calendar)calendar.clone();
	
	    c.set(Calendar.HOUR, 0);	    
	    c.set(Calendar.MINUTE, 0);
	    c.set(Calendar.SECOND, 0);
	
	    return c;
    }
}
